<template>
  <div>
    <el-select v-model="selectcun" placeholder="请选择村" :disabled="jinyong">
      <el-option
        v-for="item in cuns"
        :key="item.value"
        :label="item.name"
        :value="item.value"
      >
      </el-option>
    </el-select>
  </div>
</template>


<script>
export default {
  data() {
    return {
      cuns: [],
      selectcun: "",
      jinyong: true,
    };
  },
  methods: {
    zhenxiadecun(zhenid) {
      this.cuns = [];
      this.jinyong = true;
      this.$axios
        .get("/leader/finvillageName", {
          params: {
            zhenid: zhenid,
          },
        })
        .then((response) => {
          if (
            this.$store.state.level == "1" ||
            this.$store.state.level == "2"
          ) {
            response.data.data.ids.forEach((item, index) => {
              this.cuns.push({
                value: item,
                name: response.data.data.names[index],
              });
              this.selectcun = this.cuns[0].value;
              this.jinyong = false;
            });
          } else if (this.$store.state.level == "3") {
            console.log(this.$store.state.cunid)
            this.cuns.push({
              value: this.$store.state.cunid,
              name: this.$store.state.cunname,
            });
            this.selectcun = this.cuns[0].value;
            this.jinyong = true;
          }
        })
        .catch((err) => {
          console.log(err);
        });
    },
  },
  watch: {
    selectcun(newValue, oldValue) {
      this.$emit("selectcunfangfa", this.selectcun);
    },
  },
  created() {
    if (this.$store.state.level == "1") {
      this.jinyong = false;
    } else if (this.$store.state.level == "2") {
      this.jinyong = false;
    } else if (this.$store.state.level == "3") {
      this.jinyong = true;
    }
  },
};
</script>

<style lang="less" scoped>
</style>